home *** CD-ROM | disk | FTP | other *** search
/ Directorty Opus 5 - Magellan 2 / Opus 5 - Magellan 2.iso / Extras / D51_NUSource / Source / Routines / OpenLibraries.s < prev    next >
Text File  |  1995-08-02  |  3KB  |  75 lines

  1. *= Open Libraries =********************************************= 15-Apr-95 =*
  2. * Opens Libraries using the structure from the Variables Mem.               *
  3. * Beware: this routine does not check if it has already been run!           *
  4. * Temp001 = Stores current posn in INPUT struct.                            *
  5. * Temp002 = Stores current posn in OUTPUT struct.                           *
  6. *===========================================================================*
  7. * Error will always result in a requester, unless Force_To_Shell is set at  *
  8. * Assembly time, in which case error messages go to the shell.              *
  9. *****************************************************************************
  10. Open_Libraries
  11.     BClr    #SF1_OpnLibErr,STD_F_1(a5)    Just in case!
  12.     Lea    LibData_Start(pc),a0    Start of struc w/ name-ptrs and ver#s
  13.     Move.l    a0,Temp001(a5)
  14.     Lea    LibBases_Start(a5),a0    Start of struc to write Base-Adrs to.
  15.     Move.l    a0,Temp002(a5)
  16.  
  17.     Bsr.s    OpnLib_MainLoop        Do the main openning routine.
  18.     BTst    #SF1_OpnLibErr,STD_F_1(a5)    Any problems?
  19.     Bne    OpnLib_Error            YES = Call special error rtn.
  20.     RTS                    NO  = Return.
  21.  
  22. OpnLib_MainLoop
  23.     Move.l    Temp002(a5),a0
  24.     Lea    LibBases_Finish(a5),a4
  25.     Cmp.l    a4,a0            All libraries been openned?
  26.     Blt.s    OL_Skp1
  27.     RTS                If so, routine done.
  28.  
  29. OL_Skp1    Move.l    Temp001(a5),a0
  30.     Lea    LibNames_Start(pc),a1    -._ Point to the name of
  31.     Add.l    (a0)+,a1        -'  the lib to be openned.
  32.     Move.l    (a0)+,d0        Version of lib to be openned.
  33.     Move.l    a0,Temp001(a5)        Store updated pointer.
  34.  
  35.     N_CallExec    OpenLibrary    Attempt to open the library.
  36.  
  37.     Tst.l    d0            If failed, set flag as such.
  38.     Bne.s    OL_Skp2
  39.     BSet    #SF1_OpnLibErr,STD_F_1(a5)
  40. OL_Skp2    Move.l    Temp002(a5),a0        -._ Store base adr ptr,
  41.     Move.l    d0,(a0)+        -'  or a NULL if failed.
  42.     Move.l    a0,Temp002(a5)        Store updated pointer.
  43.  
  44.     Bra.s    OpnLib_MainLoop        Do the rest of the struct.
  45.  
  46.  
  47.     IFND    No_Requesters
  48.     INCLUDE    ASM:Source/Routines/OpenLibraries_Error_Req.s
  49.     ELSE
  50.     INCLUDE    ASM:Source/Routines/OpenLibraries_Error_Shell.s
  51.     ENDC
  52.  
  53.  
  54. *= Close Libraries =*******************************************= 15-Apr-95 =*
  55. * Closes Libraries which were openned using Open_Libraries.                 *
  56. *****************************************************************************
  57. Close_Libraries
  58.     Lea    LibBases_Start(a5),a3    Start of struc w/ Base-Adrs.
  59.  
  60. CloseLibs_MainLoop
  61.     Lea    LibBases_Finish(a5),a4
  62.     Cmp.l    a4,a3            All libraries been checked?
  63.     Blt.s    CLibs_Skp1
  64.     RTS                If so, exit.
  65. CLibs_Skp1
  66.     Tst.l    (a3)+            Does this lib need closing?
  67.     Beq.s    CloseLibs_MainLoop    If not, skip past it.
  68.  
  69.     Move.l    -4(a3),a1        Base pointer to a1 for CloseLib
  70.     Move.l    #0,-4(a3)        Null the base pointer.
  71.     Move.l    a3,-(SP)        -.
  72.     N_CallExec    CloseLibrary     |- Close the lib.
  73.     Move.l    (SP)+,a3        -'
  74.     Bra.s    CloseLibs_MainLoop    Do next library...
  75.